// pages/classify/classify.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    left: '0', //导航栏自定义属性值
    data: [],
    swiperlist:[],
    swiperslist:[],
  },
  //   导航栏切换事件
  lefttap(e) {
    this.setData({
      left: e.target.dataset.left
    })
  },
  onLoad() {
    let thiss = this
    let timer = setInterval(function() {
      const shopData = getApp().globalData.shopData;
      if (shopData.length > 0) {
        // 数据成功加载清除定时器
        clearInterval(timer);
        thiss.setData({
          data: shopData
        });
        thiss.getswiper();
      }
      
    }, 100);
  },
  getDetail(e){
    console.log(e.currentTarget.dataset.id);
    let shopId = e.currentTarget.dataset.id
    let shopList = this.data.data.filter(item => item.id == shopId)
    console.log(shopList);
    wx.navigateTo({
      url: `/pages/detail/detail?item=${JSON.stringify(shopList)}`
    })
  },
  getswiper(){
    let swiperlist = this.data.data.slice(0, 5);
    let swiperslist = this.data.data.slice(6, 11);
    this.setData({
      swiperlist: swiperlist,
      swiperslist: swiperslist,
    });
  },
})